package com.atwisdom.star.core.dao.pojo;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 
 * @TableName oaprocess_relation_instance
 */
@TableName(value ="oaprocess_relation_instance",autoResultMap = true)
@Data
public class OaprocessRelationInstance extends InstanceBase {
    /**
     * 唯一标识
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 实体uuid
     */
    @TableField(value = "instanceId")
    private String instanceId;

    /**
     * 容器类型
     */
    @TableField(value = "type")
    private String type;

    /**
     * 容器名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 容器类名
     */
    @TableField(value = "className")
    private String className;

    /**
     * 版本号
     */
    @TableField(value = "version")
    private BigDecimal version;

    /**
     * 树结构，上级或父节点id
     */
    @TableField(value = "parentId")
    private String parentId;

    /**
     * 前驱节点
     */
    @TableField(value = "prev")
    private String prev;

    /**
     * 节点名称
     */
    @TableField(value = "nodeId")
    private String nodeId;

    /**
     * 节点名称
     */
    @TableField(value = "nodeName")
    private String nodeName;

    /**
     * 节点类型
     */
    @TableField(value = "nodeType")
    private String nodeType;

    /**
     * 后继节点
     */
    @TableField(value = "link")
        private String link;

    /**
     * web 相关信息
     */
    @TableField(value = "web",typeHandler = FastjsonTypeHandler.class)
    private JSONObject web;

    /**
     * 后继节点
     */
    @TableField(value = "linkClass")
    private String linkClass;

    /**
     * 连接表名
     */
    @TableField(value = "linkTable")
    private String linkTable;

    /**
     * 属性信息
     */
    @TableField(value = "insValues",typeHandler = FastjsonTypeHandler.class)
    private JSONObject values;

    /**
     * 乐观锁
     */
    @TableField(value = "locked")
    private Integer lock;

    /**
     * 是否发布
     */
    @TableField(value = "published")
    private Boolean published;

    /**
     * 备注
     */
    @TableField(value = "comments")
    private String comments;

    /**
     * 逻辑删除
     */
    @TableField(value = "deleteFlag")
    private Boolean deleteFlag;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public OaprocessRelationInstance(){

    }
    public OaprocessRelationInstance(JSONObject jsonObject){
        this.instanceId=jsonObject.getString("instanceId");
        this.type=jsonObject.getString("type");
        this.name=jsonObject.getString("name");
        this.className=jsonObject.getString("className");
        this.version=jsonObject.getBigDecimal("version");
        this.published=jsonObject.getBoolean("published");
        this.parentId=jsonObject.getString("parentId");
        this.prev=jsonObject.getString("prev");
        this.nodeId= jsonObject.getString("nodeId");
        this.nodeName=jsonObject.getString("nodeName");
        this.nodeType=jsonObject.getString("nodeType");
        this.link=jsonObject.getString("link");
        this.linkClass=jsonObject.getString("linkClass");
        this.linkTable=jsonObject.getString("linkTable");
        this.values=jsonObject.getJSONObject("values");
        this.comments=jsonObject.getString("comments");
    }
}